<?php

include("classes/include.php");

session_start();

//echo $_FILES['fichierImport']['tmp_name'];

if(isset($_POST['suppEtu']) && isset($_POST['select']))
{
	
	$etu = new Etudiant($_POST['select']);
	
	$etu->supprimerEtudiant();
	
	header("Location: administrationEtudiant.php");
}
if(isset($_POST['importEtu']))
{
	header("Location: administrationImportEtudiant.php");
}
if(isset($_POST['generExcel']))
{
	header("Location: genererExcel.php");
}
if(isset($_POST['importFichier']) && isset($_FILES['fichierImport']) && $_FILES['fichierImport']["error"] == 0)
{
	
	//echo "pwet";
	
	$fichierAImport = $_FILES['fichierImport']['tmp_name'];
	
	$importEtu = new ImportXMLEtudiant($fichierAImport, 0);
	
	$taille = $importEtu->getNbEtuAImport();
	
	for($i = 0; $i < $taille; $i++)
	{
		
		$importEtu->setRaccourci();
		$importEtu->getNumEtu();
		
		$importEtu->insereBDD();
		
		$importEtu->next();
		
	}
	
	header("Location: administrationEtudiant.php");
}

header("Location: administrationEtudiant.php");

?>